this._frame = 0;
this._loadFile(file, width, height);
-
- // If the parent changes, we need to re-sync the animation
- // size
- this.connect('parent-set', () => this._syncAnimationSize());
}
play() {
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
this._animations = textureCache.load_sliced_image(file, width, height,
scaleFactor, resourceScale,
- () => this._syncAnimationSize());
+ () => this._loadFinished());
this._animations.set({
x_align: Clutter.ActorAlign.CENTER,
y_align: Clutter.ActorAlign.CENTER,
});
+
this.set_child(this._animations);
if (wasPlaying)
return GLib.SOURCE_CONTINUE;
}
- _syncAnimationSize() {
+ _loadFinished() {
this._isLoaded = this._animations.get_n_children() > 0;
- // this.get_size() can't be called without a parent
- if (!this._isLoaded || !this.get_parent())
- return;
-
- let [width, height] = this.get_size();
-
- for (let i = 0; i < this._animations.get_n_children(); ++i)
- this._animations.get_child_at_index(i).set_size(width, height);
-
- if (this._isPlaying)
+ if (this._isLoaded && this._isPlaying)
this.play();
}